function calculateInvoiceChecksum(invoiceCode, invoiceNumber) {
  // 根据具体的权重值进行修改
  const codeWeights = [3, 7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7];
  const numberWeights = [1, 3, 7, 9, 10, 5, 8, 4];

  // 计算发票代码的校验和
  let codeSum = 0;
  for (let i = 0; i < invoiceCode.length; i++) {
    codeSum += parseInt(invoiceCode[i]) * codeWeights[i];
  }

  // 计算发票号码的校验和
  let numberSum = 0;
  for (let i = 0; i < invoiceNumber.length; i++) {
    numberSum += parseInt(invoiceNumber[i]) * numberWeights[i];
  }

  // 计算总校验和
  const totalSum = codeSum + numberSum;

  // 计算余数
  const remainder = totalSum % 11;

  // 根据余数获取校验码
  let checksum;
  switch (remainder) {
    case 0:
      checksum = '1';
      break;
    case 1:
      checksum = '0';
      break;
    case 2:
      checksum = 'X';
      break;
    default:
      checksum = (11 - remainder).toString();
      break;
  }

  return checksum;
}
export default calculateInvoiceChecksum
// 示例用法
const invoiceCode = '123456789012'; // 替换为实际的发票代码
const invoiceNumber = '98765432'; // 替换为实际的发票号码

const checksum = calculateInvoiceChecksum(invoiceCode, invoiceNumber);
console.log('发票校验码:', checksum);
